﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GSMModemer;

namespace GSMModemer
{
    public partial class FormCmd : Form
    {
        private MainForm mainForm;
        public FormCmd()
        {
            InitializeComponent();
        }
        public FormCmd(MainForm _mainForm)
        {
            InitializeComponent();
            this.mainForm = _mainForm;
        }
        private void buttonComSend_Click(object sender, EventArgs e)
        {
            string _comstring = textBoxATCmd.Text;
            if (_comstring.Length == 0)
            {
                MessageBox.Show("错误！空命令，无法执行。");
            } 
            else
            {
                
                if (checkBoxATplus.Checked)
                {
                    _comstring = _comstring.Insert(0, "AT+");
                }

                mainForm.SendCmd2SerPort(_comstring);
            }
            
        }

        private void checkBoxATplus_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxATplus.Checked)
            {
                //textBoxATCmd.Text.Insert(0, "AT+");
                //textBoxATCmd.Text = "AT+";
                labelaATPlus.Text = "AT+";
            } 
            else
            {
                //textBoxATCmd.Text.Replace("AT+", "");
                labelaATPlus.Text = "";
            }
        }
    }
}
